import api from './index';

// Git仓库状态
export const getGitStatus = (repoPath, projectId = null) => {
  return api.post('/git/status', { 
    repo_path: repoPath,
    project_id: projectId
  });
};

// 添加所有更改到暂存区
export const gitAddAll = (repoPath, projectId = null) => {
  return api.post('/git/add-all', { 
    repo_path: repoPath,
    project_id: projectId
  });
};

// 提交更改
export const gitCommit = (repoPath, message, projectId = null) => {
  return api.post('/git/commit', {
    repo_path: repoPath,
    message: message,
    project_id: projectId
  });
};

// 添加所有更改并提交
export const gitCommitAll = (repoPath, message, projectId = null) => {
  return api.post('/git/commit-all', {
    repo_path: repoPath,
    message: message,
    project_id: projectId
  });
};

// 推送更改到远程仓库
export const gitPush = (repoPath, remote = 'origin', branch = null, projectId = null) => {
  return api.post('/git/push', {
    repo_path: repoPath,
    remote: remote,
    branch: branch,
    project_id: projectId
  });
};

// 从远程仓库拉取更改
export const gitPull = (repoPath, remote = 'origin', branch = null, projectId = null) => {
  return api.post('/git/pull', {
    repo_path: repoPath,
    remote: remote,
    branch: branch,
    project_id: projectId
  });
};

// 获取分支列表
export const gitBranch = (repoPath, projectId = null) => {
  return api.post('/git/branch', { 
    repo_path: repoPath,
    project_id: projectId
  });
};

// 切换分支
export const gitCheckout = (repoPath, branch, projectId = null) => {
  return api.post('/git/checkout', {
    repo_path: repoPath,
    branch: branch,
    project_id: projectId
  });
};

// 获取提交历史
export const gitLog = (repoPath, count = 10, projectId = null) => {
  return api.post('/git/log', {
    repo_path: repoPath,
    count: count,
    project_id: projectId
  });
};

// 克隆仓库
export const gitClone = (repoUrl, projectFolderPath = null, projectId = null) => {
  return api.post('/git/clone', { 
    repo_url: repoUrl,
    project_folder_path: projectFolderPath,
    project_id: projectId
  });
}; 